<%@ WebHandler Language="C#" Class="Portlet2" %>

using System;
using System.Web;
using System.Threading;
using System.Text;
using System.Web.SessionState;
using System.Collections.Generic;
using System.Collections;
 
public class Portlet2 : IHttpHandler, IReadOnlySessionState{

 
    String fechainicio = "";
    String fechafin = "";
    StringBuilder sb = new StringBuilder();
 

    public void ProcessRequest(HttpContext context)
    {

        context.Response.ContentType = "text/plain";
        //List<BETRHisEmergencia> lista = null;
        //BLTRHisEmergencia emergencia = new BLTRHisEmergencia();
        //String inicio = context.Request["inicio"];     

        //if (inicio != "0")
        //{

            //fechainicio = Utils.getStringFechaYYMMDDHHMM(context.Request["fechainicio"]) + " 00:00:00";
            //fechafin = Utils.getStringFechaYYMMDDHHMM(context.Request["fechafin"]) + " 23:59:00";


            //lista = emergencia.fnChartxSucursal(fechainicio, fechafin);

            //if (lista.Count != 0)
            //{            
            //    sb = getConstruccionPie(lista);
            //}
            //else { 
                sb = cargaInicial(); 
            //}

        //}
        //else { sb = cargaInicial();  }

        context.Response.Write(sb.ToString());
    }

    //public StringBuilder getConstruccionPie(List<BETRHisEmergencia> lista)
    //{
    //    if (lista != null && lista.Count > 0)
    //    {
    //        Int64 i = 0;
    //        String var1 = "<graph showNames='1'  caption=''  decimalPrecision='0'>";

    //        foreach (BETRHisEmergencia bean in lista)
    //        {
    //            string var = i == 0 ? var1 : "/>";
    //            string varF = i == lista.Count - 1 ? "/></graph>" : "";

    //            sb.Append(String.Format(var + "{0} {1} {2}" + varF,
    //            "<set name='" + HttpUtility.HtmlEncode(bean.AvrSucursal) + "'",
    //            "hoverText='" + HttpUtility.HtmlEncode(bean.Sucursal) + "'",
    //            "value='" + HttpUtility.HtmlEncode(bean.NumEmergencias) + "'"
    //            ));

    //            i++;
    //        }
    //    }
    //    return sb;
    //}
    
    
    public StringBuilder cargaInicial() 
    {

        byte[] randBytes = new byte[108];
        Random randNum = new Random();
        randNum.NextBytes(randBytes);


        //sb.Append(String.Format("  <set name='' hoverText='' value='{0}' />", 1));
        
        
        sb.Append("<graph showNames='1'  caption=''  decimalPrecision='0'>"); 
        //sb.Append(String.Format("  <set name='' hoverText='' value='{0}' />", randBytes[1]));
        sb.Append(String.Format("  <set name='India' hoverText='wal' value='{0}' />", randBytes[2]));
        sb.Append(String.Format("  <set name='England' hoverText='wal' value='{0}' />", randBytes[3]));
        sb.Append(String.Format("  <set name='Italy' hoverText='wal' value='{0}' />", randBytes[4]));
        sb.Append(String.Format("  <set name='Canada' hoverText='wal' value='{0}' />", randBytes[5]));
        sb.Append(String.Format("  <set name='Germany' hoverText='wal' value='{0}' />", randBytes[6]));

        sb.Append("</graph>");

        return sb; 
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

    private int RandomNumber(int min, int max)
    {
        Random random = new Random();
        return random.Next(min, max);
    }

}